*******************************
** OPEN STATA 14 **************
*******************************

** TABLES 1 and 2

* I. Reported Results: Entire Border

* II. Results now excluding Austrian Province

* III. Results excluding Austrian Segment (Austrian Province & powiat to E of Austrian-Russian border)

* IV. Results excluding "Lite" -- defined as terrirories under Poland in the interwar period but claimed by Lithuania:

	* voivodina of Wilenska
	* powiats of Suwalki, Augustow, Grodno, Sokolka in Bilatostockie voivodina;
	* powiats of Szczuczyn, Lida, Wolo in Nowogrodek voivodina

** ADDITIONAL TESTS
	
* V. Results with higher-order polynomials

* VI. Results with different kernel functions



use "POLITICAL EMANCIPATION -- POLAND DATA SET.dta", clear

global covariates "jewishpop"

************
* TABLE 1 *
************

* ENTIRE BORDER (REPORTED IN PAPER)

* APSR Data Editors Note: Estimates in the paper were produced and verified using version 8.0.2  of the RDROBUST package. 
* On newer versions of the package you may need to specify stdvars(on). Future version of the RDROBUST package will alternatively 
* allow user to specify the reverse algorithm as syminv() (instead of the current cholesky-based inversion). This will also exactly 
* reproduce the results. Finally, using the current R version of the RDROBUST package will reproduce the results produced in the paper.

rdrobust zionschoolsno_any distance if type=="ville", covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capzionschoolsno_any distance if type=="ville", kernel(triangular) p(1) bwselect(mserd) all

rdrobust max_zschools distance if jewishpop>100, covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capmax_zschools_census distance if jewishpop>100, kernel(triangular) p(1) bwselect(mserd) all

rdrobust jewishschoolsno_any distance if type=="ville", covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capjewishschoolsno_any distance if type=="ville", kernel(triangular) p(1) bwselect(mserd) all


* BORDER WITHOUT AUSTRIAN PROVINCE

rdrobust zionschoolsno_any distance if type=="ville" & austria_preww1!=1 , covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capzionschoolsno_any distance if type=="ville" & austria_preww1!=1, kernel(triangular) p(1) bwselect(mserd) all

rdrobust max_zschools distance if jewishpop>100 & austria_preww1!=1 , covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capmax_zschools_census distance if jewishpop>100 & austria_preww1!=1 , kernel(triangular) p(1) bwselect(mserd) all

rdrobust jewishschoolsno_any distance if type=="ville" & austria_preww1!=1, covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capjewishschoolsno_any distance if type=="ville" & austria_preww1!=1 , kernel(triangular) p(1) bwselect(mserd) all


* BORDER WITHOUT AUSTRIAN SEGMENT

* Generate excluded powiats east of Galizia

*gen border_austriarussia=0
replace border_austriarussia=1 if voivodina=="Wolynskie" & powiat=="Krzemieniec"
replace border_austriarussia=1 if voivodina=="Wolynskie" & powiat=="Dubno"
replace border_austriarussia=1 if voivodina=="Wolynskie" & powiat=="Horochow"


rdrobust zionschoolsno_any distance if type=="ville" & austria_preww1!=1  & border_austriarussia!=1 , covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capzionschoolsno_any distance if type=="ville" & austria_preww1!=1  & border_austriarussia!=1, kernel(triangular) p(1) bwselect(mserd) all

rdrobust max_zschools distance if jewishpop>100 & austria_preww1!=1  & border_austriarussia!=1, covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capmax_zschools_census distance if jewishpop>100 & austria_preww1!=1 & border_austriarussia!=1 , kernel(triangular) p(1) bwselect(mserd) all

rdrobust jewishschoolsno_any distance if type=="ville" & austria_preww1!=1  & border_austriarussia!=1, covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capjewishschoolsno_any distance if type=="ville" & austria_preww1!=1  & border_austriarussia!=1, kernel(triangular) p(1) bwselect(mserd) all


* BORDER WITHOUT "LITE"

rdrobust zionschoolsno_any distance if type=="ville" & lite!=1 , covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capzionschoolsno_any distance if type=="ville" & lite!=1, kernel(triangular) p(1) bwselect(mserd) all

rdrobust max_zschools distance if jewishpop>100 & lite!=1 , covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capmax_zschools_census distance if jewishpop>100 & lite!=1 , kernel(triangular) p(1) bwselect(mserd) all

rdrobust jewishschoolsno_any distance if type=="ville" & lite!=1, covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust capjewishschoolsno_any distance if type=="ville" & lite!=1 , kernel(triangular) p(1) bwselect(mserd) all



***********
* TABLE 2 *
***********

* ENTIRE BORDER (REPORTED IN PAPER)

rdrobust max_somehebrew distance, covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust cap_maxsomehebrew distance, kernel(triangular) p(1) bwselect(mserd) all


* BORDER WITHOUT AUSTRIAN PROVINCE

rdrobust max_somehebrew distance if austria_preww1!=1 , covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust cap_maxsomehebrew distance if austria_preww1!=1, kernel(triangular) p(1) bwselect(mserd) all


* BORDER WITHOUT AUSTRIAN SEGMENT

rdrobust max_somehebrew distance if austria_preww1!=1  & border_austriarussia!=1, covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust cap_maxsomehebrew distance if austria_preww1!=1  & border_austriarussia!=1, kernel(triangular) p(1) bwselect(mserd) all



* BORDER WITHOUT "LITE"

rdrobust max_somehebrew distance if lite!=1 , covs($covariates) kernel(triangular) p(1) bwselect(mserd) all

rdrobust cap_maxsomehebrew distance if lite!=1, kernel(triangular) p(1) bwselect(mserd) all




** ADDITIONAL TESTS
	
* V. Results with higher-order polynomials

* quadratic polynomials

rdrobust zionschoolsno_any distance if type=="ville", covs($covariates) kernel(triangular) p(2) bwselect(mserd) all
rdrobust capzionschoolsno_any distance if type=="ville", kernel(triangular) p(2) bwselect(mserd) all
rdrobust max_zschools distance if jewishpop>100, covs($covariates) kernel(triangular) p(2) bwselect(mserd) all
rdrobust capmax_zschools_census distance if jewishpop>100, kernel(triangular) p(2) bwselect(mserd) all
rdrobust jewishschoolsno_any distance if type=="ville", covs($covariates) kernel(triangular) p(2) bwselect(mserd) all
rdrobust capjewishschoolsno_any distance if type=="ville", kernel(triangular) p(2) bwselect(mserd) all

rdrobust max_somehebrew distance, covs($covariates) kernel(triangular) p(2) bwselect(mserd) all
rdrobust cap_maxsomehebrew distance, kernel(triangular) p(1) bwselect(mserd) all

* VI. Results with different kernel functions

* Uniform

rdrobust zionschoolsno_any distance if type=="ville", covs($covariates) kernel(uniform) p(1) bwselect(mserd) all
rdrobust capzionschoolsno_any distance if type=="ville", kernel(uniform) p(1) bwselect(mserd) all
rdrobust max_zschools distance if jewishpop>100, covs($covariates) kernel(uniform) p(1) bwselect(mserd) all
rdrobust capmax_zschools_census distance if jewishpop>100, kernel(uniform) p(1) bwselect(mserd) all
rdrobust jewishschoolsno_any distance if type=="ville", covs($covariates) kernel(uniform) p(1) bwselect(mserd) all
rdrobust capjewishschoolsno_any distance if type=="ville", kernel(uniform) p(1) bwselect(mserd) all

rdrobust max_somehebrew distance, covs($covariates) kernel(uniform) p(1) bwselect(mserd) all
rdrobust cap_maxsomehebrew distance, kernel(uniform) p(1) bwselect(mserd) all

* Epanechnikov

rdrobust zionschoolsno_any distance if type=="ville", covs($covariates) kernel(epanechnikov) p(1) bwselect(mserd) all
rdrobust capzionschoolsno_any distance if type=="ville", kernel(epanechnikov) p(1) bwselect(mserd) all
rdrobust max_zschools distance if jewishpop>100, covs($covariates) kernel(epanechnikov) p(1) bwselect(mserd) all
rdrobust capmax_zschools_census distance if jewishpop>100, kernel(epanechnikov) p(1) bwselect(mserd) all
rdrobust jewishschoolsno_any distance if type=="ville", covs($covariates) kernel(epanechnikov) p(1) bwselect(mserd) all
rdrobust capjewishschoolsno_any distance if type=="ville", kernel(epanechnikov) p(1) bwselect(mserd) all

rdrobust max_somehebrew distance, covs($covariates) kernel(epanechnikov) p(1) bwselect(mserd) all
rdrobust cap_maxsomehebrew distance, kernel(epanechnikov) p(1) bwselect(mserd) all
